<?php
namespace app\admin\controller;

use app\admin\logic\RoleLogic;
use think\Request;

class Role extends Base{
	private $roleLogic;
	public function __construct( Request $request = null ) {
		parent::__construct( $request );
		$this->roleLogic=new RoleLogic();
	}

	// 列表页
	public function index(){
		$roles=$this->roleLogic->query('');
		$this->assign('list',$roles);
		return $this->fetch();
	}

	//新增用户页面
	public function add($id=0){
		$user=null;
		if($id>0){
			$user=$this->roleLogic->findOne($id);
		}
		$this->assign('user',$user);
		return $this->fetch();
	}

	//保存数据
	public function doAdd($param=''){
		$userArr=json_decode($param,true);
		$res=$this->roleLogic->addUser($userArr);
		return $res;
	}

	//删除数据
	public function del($id=0){
		$res=$this->roleLogic->del($id);
		return $res;
	}
}


